package com.GainLoop.Api;

import org.alexd.jsonrpc.JSONRPCException;
import org.json.JSONException;

import com.GainLoop.Api.Entity.Gain;
import com.GainLoop.Api.Entity.Tag;

public class Tags extends ApiAbstract {


//	public ApiResponseObject<Tag> create(Tag tag) throws JSONException, JSONRPCException
//	{
//		if(tag.getId() != 0) {
//			throw new ApiException("gain id must not set");
//		}
//		 
//		return new ApiResponseObject<Tag>(GetClient().callJSONObject("tags.create", tag.toObject()), Tag.class);
//	}
	
	public ApiResponseObject<Tag> getById(long id) throws JSONException, JSONRPCException
	{
		return new ApiResponseObject<Tag>(GetClient().callJSONObject("tags.getById", id), Tag.class);
	}
	
	public ApiResponseObject<Tag> getByName(String name) throws JSONException, JSONRPCException
	{
		return new ApiResponseObject<Tag>(GetClient().callJSONObject("tags.getByName", name), Tag.class);
	}
	
	public ApiResponseArray<Tag> getAllByGain(Gain gain) throws JSONException, JSONRPCException
	{
		if(gain.getId() == 0) {
			throw new ApiException("gain id must be set");
		}
		
		return new ApiResponseArray<Tag>(GetClient().callJSONObject("tags.getAllByGainId", gain.getId()), Tag.class);
	}
	
}
